#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
using namespace std;

class Solution {
	int n, m;
	int get(int s, int bit)
	{
		return s / bit % 3;
	}
	int set(int s, int bit, int val)
	{
		return s - get(s, bit) * bit + val * bit;
	}
	int cal(int i, int j, int s, int in, int ex, int bit)
	{
		if (i == n) {
			return 0;
		}
		if (j == m) {
			return cal(i + 1, 0, s, in, ex, 1);
		}

		int ans = cal(i, j + 1, set(s, bit, 0), in, ex, bit * 3);

		int up = get(s, bit);
		int left = j == 0 ? 0 : get(s, bit / 3);

		int pre = (up == 1 ? -30 : up == 2 ? 20 : 0) + (left == 1 ? -30 : left == 2 ? 20 : 0);
		int cnt = (up == 0 ? 0 : 1) + (left == 0 ? 0 : 1);

		if (in > 0) {
			ans = max(ans, cal(i, j + 1, set(s, bit, 1), in - 1, ex, bit * 3) + pre + 120 - cnt * 30);
		}

		if (ex > 0) {
			ans = max(ans, cal(i, j + 1, set(s, bit, 2), in, ex - 1, bit * 3) + pre + 40 + cnt * 20);
		}

		return ans;
	}

    public:
	int getMaxGridHappiness(int m, int n, int introvertsCount, int extrovertsCount)
	{
		Solution::n = max(m, n);
		Solution::m = min(m, n);
		return cal(0, 0, 0, introvertsCount, extrovertsCount, 1);
	}
};

int main()
{
	int m = 3, n = 1, introvertsCount = 2, extrovertsCount = 1;
	//int m = 2, n = 3, introvertsCount = 1, extrovertsCount = 2;
	cout << Solution().getMaxGridHappiness(m, n, introvertsCount, extrovertsCount) << endl;
	return 0;
}